how to use function "hasInPlace"

Hello,

I have basis knowledge in DXL and I don't know how to use a function, could someone help me?

In a dialog-box, I want to update the color of an area depending of the text entered in a canvas. I have found in DXL help that the function hasInPlace should be used. But this function looks very hard for me as a function is passed as argument and because it used trigger and event.

I have search in all DXL example files, and on many www sites but I have not found information on this function. Could someone send an example of use of this function: how is defined and used the callback function and how/where to use this function?

Best regards,

JLacroix
jlacroix - Tue Nov 03 11:20:01 EST 2009

Re: how to use function "hasInPlace"
jlacroix - Tue Nov 03 11:38:20 EST 2009

Hello again,

Sorry, it's not a text entered in a "canvas", but entered in a "field".

Regards,

JLacroix

Re: how to use function "hasInPlace"
llandale - Tue Nov 03 13:14:58 EST 2009

Don't know about Canvases but I do understand the nuances of the manual:

hasInPlace 
Declaration 
     void hasInPlace(DBE da, void cb(DBE el, event)) 
Operation 
     The callback function is called on one of two event types. The event type is the second argument
     passed to callback function with one of the following values:
 
inPlaceTextFilled  the text box is full and needs to be expanded  
inPlaceTextChange  the text box contents has been modified


This says you need to have a callback function to handle the event associated with the Canvas. That callback function must have return value 'void' and has two input parameters, 1: type DBE, and 2: ... golly, it doesn't say!!! Well, looking at the doors.exe in a manner that only 5 folks in the world know about (the 5 folks who don't know about the other 1000 or so folks...), we see that variable 'inPlaceTextFilled' is type InPlaceEditEvent. Thus, perhaps this will get you started:

 

void  clbkCanvasEvent(DBE dbeCanvas, InPlaceEditEvent Event)
{     if     (Event == inPlaceTextFilled)
      {  Handle a Text Filled event in the dbeCanvas, perhaps make it taller
      }
      elseif (Event == inPlaceTextChange)
      {  Handle the Text Change event in the dbeCanvas
      }
      else
      {  Tell Louie he is out to lunch
      }
}     // end clbkCnavasEvent()
 
DBE   dbeMyField = some sort of canvas declaration
      hasInPlace(dbeMyField, clbkCanvasEvent)  // Associate Events on the Canvas with the Callback



While we are on that same DXL help page, an 'editor' is type InPlaceBox__.



 

 

 

  • Louie

 

 

Re: how to use function "hasInPlace"
jlacroix - Wed Nov 04 09:01:03 EST 2009

llandale - Tue Nov 03 13:14:58 EST 2009

Don't know about Canvases but I do understand the nuances of the manual:

hasInPlace 
Declaration 
     void hasInPlace(DBE da, void cb(DBE el, event)) 
Operation 
     The callback function is called on one of two event types. The event type is the second argument
     passed to callback function with one of the following values:
 
inPlaceTextFilled  the text box is full and needs to be expanded  
inPlaceTextChange  the text box contents has been modified


This says you need to have a callback function to handle the event associated with the Canvas. That callback function must have return value 'void' and has two input parameters, 1: type DBE, and 2: ... golly, it doesn't say!!! Well, looking at the doors.exe in a manner that only 5 folks in the world know about (the 5 folks who don't know about the other 1000 or so folks...), we see that variable 'inPlaceTextFilled' is type InPlaceEditEvent. Thus, perhaps this will get you started:

 

void  clbkCanvasEvent(DBE dbeCanvas, InPlaceEditEvent Event)
{     if     (Event == inPlaceTextFilled)
      {  Handle a Text Filled event in the dbeCanvas, perhaps make it taller
      }
      elseif (Event == inPlaceTextChange)
      {  Handle the Text Change event in the dbeCanvas
      }
      else
      {  Tell Louie he is out to lunch
      }
}     // end clbkCnavasEvent()
 
DBE   dbeMyField = some sort of canvas declaration
      hasInPlace(dbeMyField, clbkCanvasEvent)  // Associate Events on the Canvas with the Callback



While we are on that same DXL help page, an 'editor' is type InPlaceBox__.



 

 

 

  • Louie

 

 

Hello,

Thanks for your answer. I understand how to use it, I have tried something like that but without the "InPlaceEditEvent", it was not working.

But I have another question...

The hasInPlace function could be used only on canvas, actually I use a "field" to get a text editor, and I can't trigger update function for each modification of the "field".

I think I must not use the "field" but use a "canvas" declared as an inPlace Editor (that way, caracters could be enterred in canvas area, and function is called for each update), but I don't know how to do that...

Do you know how to declared a canvas as an editable text area?

Thanks for your help

JLacroix

Re: how to use function "hasInPlace"
ePiallat - Wed Nov 04 10:19:49 EST 2009

jlacroix - Wed Nov 04 09:01:03 EST 2009
Hello,

Thanks for your answer. I understand how to use it, I have tried something like that but without the "InPlaceEditEvent", it was not working.

But I have another question...

The hasInPlace function could be used only on canvas, actually I use a "field" to get a text editor, and I can't trigger update function for each modification of the "field".

I think I must not use the "field" but use a "canvas" declared as an inPlace Editor (that way, caracters could be enterred in canvas area, and function is called for each update), but I don't know how to do that...

Do you know how to declared a canvas as an editable text area?

Thanks for your help

JLacroix

Hello,

Three in-place boxes are created when you first invoke the hasInPlace function.
The tricky part is they are displayed by default, but with a size of zero.

So you first have to "show" your inPlaceBox with the inPlaceMove function.
Note that this function must be invoked after dialog is realised.
Take a look at the quick and dirty example below derived from Louie's one:

void clbkCanvasRepaint(DBE dbeCanvas) {
   // nothing needed yet
}
 
void  clbkCanvasEvent(DBE dbeCanvas, InPlaceEditEvent Event)
{     if     (Event == inPlaceTextFilled)
      { print "Size changed. Size:" (inPlaceTextHeight dbeCanvas) "\n"
      }
      elseif (Event == inPlaceTextChange)
      {  print "Text changed. Text:" (string inPlaceGet (dbeCanvas, inPlaceText)) "\n"
      }
      else
      {  print "Never happens (I hope!)\n"
      }
}     // end clbkCnavasEvent()
 
DB db = create "Example"
DBE   dbeMyRichCanvas = canvas (db,100,100,clbkCanvasRepaint)
hasInPlace(dbeMyRichCanvas, clbkCanvasEvent)  // Associate Events on the Canvas with the Callback
realize db
inPlaceMove (dbeMyRichCanvas, inPlaceText, 0,0,100,100)
inPlaceSet  (dbeMyRichCanvas, inPlaceText, "Hello World")
show db


Note that in-Place Boxes were not meant to be displayed continuously: theorically, content should be displayed with the repaint callback, and showing an inPlaceBox should be linked to the double-click event.

Re: how to use function "hasInPlace"
llandale - Wed Nov 04 13:12:45 EST 2009

jlacroix - Wed Nov 04 09:01:03 EST 2009
Hello,

Thanks for your answer. I understand how to use it, I have tried something like that but without the "InPlaceEditEvent", it was not working.

But I have another question...

The hasInPlace function could be used only on canvas, actually I use a "field" to get a text editor, and I can't trigger update function for each modification of the "field".

I think I must not use the "field" but use a "canvas" declared as an inPlace Editor (that way, caracters could be enterred in canvas area, and function is called for each update), but I don't know how to do that...

Do you know how to declared a canvas as an editable text area?

Thanks for your help

JLacroix

I think its DOORS 9.0 that has a bug that hitting the EOL in a field does NOT trigger a normal callback, which has the form void clbkField(DBE dbeXX); and is defined using set(dbeField, clbkField)

Re: how to use function "hasInPlace"
jlacroix - Thu Nov 05 04:25:30 EST 2009

ePiallat - Wed Nov 04 10:19:49 EST 2009

Hello,

Three in-place boxes are created when you first invoke the hasInPlace function.
The tricky part is they are displayed by default, but with a size of zero.

So you first have to "show" your inPlaceBox with the inPlaceMove function.
Note that this function must be invoked after dialog is realised.
Take a look at the quick and dirty example below derived from Louie's one:

void clbkCanvasRepaint(DBE dbeCanvas) {
   // nothing needed yet
}
 
void  clbkCanvasEvent(DBE dbeCanvas, InPlaceEditEvent Event)
{     if     (Event == inPlaceTextFilled)
      { print "Size changed. Size:" (inPlaceTextHeight dbeCanvas) "\n"
      }
      elseif (Event == inPlaceTextChange)
      {  print "Text changed. Text:" (string inPlaceGet (dbeCanvas, inPlaceText)) "\n"
      }
      else
      {  print "Never happens (I hope!)\n"
      }
}     // end clbkCnavasEvent()
 
DB db = create "Example"
DBE   dbeMyRichCanvas = canvas (db,100,100,clbkCanvasRepaint)
hasInPlace(dbeMyRichCanvas, clbkCanvasEvent)  // Associate Events on the Canvas with the Callback
realize db
inPlaceMove (dbeMyRichCanvas, inPlaceText, 0,0,100,100)
inPlaceSet  (dbeMyRichCanvas, inPlaceText, "Hello World")
show db


Note that in-Place Boxes were not meant to be displayed continuously: theorically, content should be displayed with the repaint callback, and showing an inPlaceBox should be linked to the double-click event.

Hello,

Thanks, that's exactly what I was looking for. I understand now: a canvas is a box, and the text editor is only an area of this box, like a rectangle or a picture.

But I have a trouble with your function: The trigger on event "inPlaceTextChange" doesn't work. In your example, the text "Hello World" is displayed, if with your mouse you select the "o" letter and replace it with a "a", then text displayed is "Hello Warld" and no event was triggered.

This is perhaps linked to my version od Doors, I use the 8.1.0.8

Thanks again for your support.

JLacroix

Re: how to use function "hasInPlace"
ePiallat - Thu Nov 05 05:44:27 EST 2009

jlacroix - Thu Nov 05 04:25:30 EST 2009
Hello,

Thanks, that's exactly what I was looking for. I understand now: a canvas is a box, and the text editor is only an area of this box, like a rectangle or a picture.

But I have a trouble with your function: The trigger on event "inPlaceTextChange" doesn't work. In your example, the text "Hello World" is displayed, if with your mouse you select the "o" letter and replace it with a "a", then text displayed is "Hello Warld" and no event was triggered.

This is perhaps linked to my version od Doors, I use the 8.1.0.8

Thanks again for your support.

JLacroix

Pas de quoi ;)